using System;
using System.Collections.Generic;
using System.Text;
using XProject.Entity;
using System.Data.OleDb;
namespace XProject.DAO
{
    class EventTypeDAO:DBAccess
    {
        #region sql command
        string SQL_SELECT_ALL = "select * from EventType";
        #endregion
        #region fields
        string message="";
        #endregion
        #region properties
        public string Message
        {
            get { return message; }
        }
        #endregion
        /// <summary>
        /// Select all event type
        /// </summary>
        /// <returns></returns>
        public IList<EventType> GetAllType()
        {
            IList<EventType> list=new List<EventType>();
            try
            {
                OleDbCommand command = new OleDbCommand(SQL_SELECT_ALL, conn);
                if (Connect())
                {
                    OleDbDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        EventType type = new EventType();
                        type.TypeID = dr.GetByte(0);
                        type.TypeName = dr.GetString(1);
                        list.Add(type);
                    }
                    Disconnect();
                }
            }
            catch (OleDbException ex)
            {
                message = ex.Message;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return list;
        }
    }
}
